import java.io.IOException;
import java.time.LocalDateTime;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;

/**
 * Create By IntelliJ IDEA
 *
 * @Author: jsonor
 * @Create-Time: 2017/9/19 11:15
 * @Description: Hello world Servlet
 */
public class HelloWorldServlet extends HttpServlet {


  private static final Logger logger = Logger.getLogger(HelloWorldServlet.class);

  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

    // new Date()
    // jdk 1.8
    // a/t + enter
    // add maven 依赖 --> add jdk 1.8
    // LocalDateTime : Local date time . now()
    logger.debug("some one visit my web application at " + LocalDateTime.now());

    // resp : response 响应
    // getWriter : 获取输出流
    // write 往流里面写入信息
    resp.getWriter().write(LocalDateTime.now().toString());

    // tomcat 自动包装成http协议的内容，将其发送出去
  }


  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    super.doPost(req, resp);
  }
}
